﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Web;

namespace WMSTest.OnlineMapRequests
{
    class HttpGetRequest : HttpRequest
    {
        public HttpGetRequest(string endpointUrl)
            : base(endpointUrl)
        {
        }

        public override HttpWebResponse IssueRequest()
        {

            // Build a string with all the params, properly encoded.
            StringBuilder p = new StringBuilder();
            foreach (string key in paramTable.Keys)
            {
                if (paramTable[key] != null)
                {
                    p.Append(key);
                    p.Append("=");
                    p.Append(HttpUtility.UrlEncode(paramTable[key].ToString()));
                    p.Append("&");
                }
            }

            HttpWebRequest req = WebRequest.Create(endpointUrl+'?'+p.ToString()) as HttpWebRequest;
            
            return req.GetResponse() as HttpWebResponse ;
        }
    }
}
